# Kernel config based on: arch/arm/configs/bravo_defconfig

pkgname="linux-htc-bravo"
pkgver=3.0.16
pkgrel=8
pkgdesc="HTC Desire kernel from spezi77"
arch="armhf"
_carch="arm"
_flavor="htc-bravo"
url="https://github.com/spezi77/android_kernel_htc_qsd8k_3.0"
license="GPL2"
options="!strip !check !tracedeps"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev xz"
HOSTCC="${CC:-gcc}"
HOSTCC="${HOSTCC#${CROSS_COMPILE}}"

# Source
_repository="android_kernel_htc_qsd8k_3.0"
_commit="4bc19919f805777947c243e6c2ed41ece530488b"
_config="config-${_flavor}.armhf"
source="
	$pkgname-$_commit.tar.gz::https://github.com/spezi77/${_repository}/archive/${_commit}.tar.gz
	$_config
	compiler-gcc6.h
"
builddir="$srcdir/${_repository}-${_commit}"

prepare() {
	default_prepare

	# gcc6 support
	cp -v "$srcdir/compiler-gcc6.h" "$builddir/include/linux/"

	cp "$srcdir"/$_config "$builddir"/.config
	yes "" | make ARCH="$_carch" HOSTCC="$HOSTCC" oldconfig
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine"
}

package() {
	install -Dm644 "$builddir/arch/arm/boot/zImage" \
		"$pkgdir/boot/vmlinuz-$_flavor"

	install -D "$builddir/include/config/kernel.release" \
		"$pkgdir/usr/share/kernel/$_flavor/kernel.release"
}

sha512sums="94929945d6fcb4428f320325ced207a9888cd758357766ef914c4ca2d5cea4b9cced77275463dac316591ba942e6e1514fec8c1f8e11c8324155116785ffb277  linux-htc-bravo-4bc19919f805777947c243e6c2ed41ece530488b.tar.gz
49460380237b391b9e0b79e3bad3ff65ea423a8ed0790501ae4c69652ff0799f21fa639bcb14014df81b5bbe361d0bf4665233d562d84047598bfca51b16dfc4  config-htc-bravo.armhf
d80980e9474c82ba0ef1a6903b434d8bd1b092c40367ba543e72d2c119301c8b2d05265740e4104ca1ac5d15f6c4aa49e8776cb44264a9a28dc551e0d1850dcc  compiler-gcc6.h"
